﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XiaoYuStock.Model;
using XiaoYuStock.Model.Models;
using XiaoYuStock.Model.Request;
using XiaoYuStockAnalysis.BusinessLogic.Business;
using XiaoYuStock.Core;
using XiaoYuStock.Core.Entities;
namespace XiaoYuStock.WebApp.Controllers
{
    public class ShareListController : BaseController
    {
        private ShareListDataBusiness shareBus = new ShareListDataBusiness();
        //
        // GET: /Book/

        public ActionResult Index(ShareRequest request)
        {
            request.PageSize = 20;
            var total = 0;
            var result = shareBus.GetList(request,out total);

            return View(result);
        }


        /// <summary>
        /// 添加自选
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult AddSelfTarget(string shareCode)
        {
            ShareTargetBusiness busi = new ShareTargetBusiness();
            ShareTarget model = new ShareTarget();
            model.ShareCode = shareCode;
            model.CreateDate = DateTime.Now;
            model.CreateUserId = 0;
            model.IsOpenCheck = false;
            model.SortId = 0;
            model.Status = (int)ShareState.Active;
            var result= busi.Save(model);
            return Json(new { status = result});
        }


        [HttpPost]
        public ActionResult Edit(string ShareCode, FormCollection collection)
        {
           
            return this.RefreshParent();
        }
    }
}
